home *** CD-ROM | disk | FTP | other *** search
/ BCI NET 2 / BCI NET 2.iso / archives / programming / source / graphicgems4.lha / GemsIV / graph_layout / README < prev    next >
Encoding:
Text File  |  1995-02-06  |  7.9 KB  |  281 lines

  1. C++ code from the article
  2. "Dynamic Layout Algorithm to Display General Graphs"
  3. by Laszlo Szirmay-Kalos, szirmay@fsz.bme.hu
  4. in "Graphics Gems IV", Academic Press, 1994
  5.  
  6.  
  7.  
  8. Installation of the Dynamic Layout Program ( graph )
  9. ====================================================
  10.  
  11. This program can be installed under UNIX/X-WINDOW or under
  12. MS-WINDOWS environment.
  13.  
  14. To install under UNIX/X-WINDOWS use the make utility, 
  15. -----------------------------------------------------
  16. which generates the executable program called "graph" relying on the Makefile:
  17.  
  18.         make -f Makefile
  19.  
  20. Makefile supposes:
  21.  
  22.     - gcc (gnu C++ compiler)
  23.     - XLib header files in /usr/include/X11R4
  24.     - XLib library in /usr/lib/X11R4
  25.  
  26. If your system has the XLib header files and libraries in different
  27. locations please modify the INCLUDES and LDFLAGS flags in the
  28. Makefile.  Since the program has been written to meet the AT&T C++
  29. standard, even if you have a C++ compiler other than gcc, you can
  30. expect to compile the program without difficulties after modifying the
  31. CC and CFLAGS.  For the sake of maximum compatibility the program does
  32. not take advantage of advanced widget sets ( such as Motif ), neither
  33. does it require color screen.
  34.  
  35.  
  36. To install under DOS/MS-WINDOWS 3.x , 
  37. -----------------------------------------------------
  38. a UNIX shell script (mswin.gen) should be invoked first, 
  39. which converts the file names according to the requirements of DOS 
  40. and Borland C++ compiler. This shell script expects a directory as command
  41. line argument and will place the generated file to the given directory:
  42.         
  43.         mswin.gen mswin
  44.  
  45. will generate the files in mswin directory.        
  46.  
  47. Having generated the files, they should to transferred to a
  48. DOS/MS-WINDOWS system and the make utility of the borland C++ 3.1
  49. compiler can be used to generate the executable file ( called graph ),
  50. which will run under MS-WINDOWS environment.
  51.  
  52. The information file of the make is called graph.mak here, which supposes:
  53.     - borland C++ compiler, version 3.1
  54.     
  55.  
  56. Running the graph program:
  57. ==========================
  58. Under UNIX/X-WINDOW the program can be started by typing "graph" with a
  59. file name argument referring to the definition of a graph:
  60.  
  61.         graph g20.dat
  62.  
  63. Under DOS/MS-WINDOWS you should also start MS-WINDOWS as for example:
  64.         
  65.         win graph g20.dat
  66.         
  67.  
  68. Two sample files are included in this package: g.dat, g20.dat. In addition
  69. to that, you can also define graphs in the format described below.
  70.  
  71. Having started the program, it will display the original arrangement of
  72. the graph on the screen, which can be altered by the layout algorithm
  73. by pressing the key <L>, or can be arranged randomly by pressing the
  74. key <R>.  Key <Q> gets the program to quit, while saving the last
  75. arrangement in file ggg.dat.
  76.  
  77.  
  78.  
  79. Files of the program
  80. =====================
  81.  
  82. The complete file set consists of the following files:
  83.  
  84. 1. C++ Source files: 
  85.     layout.C = Dynamic layout and Initial Placement algorithms
  86.     fileio.C = File I/O operations
  87.     graph.C  = Manipulation of Graph data structure and event handlers
  88.     vector.C = 2D vector operations
  89.     window.C = class library to interface XLib 
  90.     mswindow.C = class library to interface MS-WINDOWS
  91.     
  92. 2. C++ Header files:
  93.     defines.h
  94.     fileio.hxx
  95.     graph.hxx
  96.     vector.hxx
  97.     window.hxx
  98.     mswindow.hxx
  99.  
  100. 3. README files:
  101.     README = you are reading this file!
  102.     
  103. 4. Program generation files:
  104.     Makefile = makefile for X-WINDOWS
  105.     graph.mak = makefile for MS-WINDOWS
  106.     mswin.gen = UNIX shell script to generate dos file names:
  107.             layout.C     -> layout.cpp
  108.             fileio.C     -> fileio.cpp
  109.             graph.C      -> graph.cpp
  110.             vector.C     -> vector.cpp
  111.             mswindow.C   -> mswindow.cpp
  112.             defines.h    -> defines.h
  113.             fileio.hxx   -> fileio.hxx
  114.             graph.hxx    -> graph.hxx
  115.             vector.hxx   -> vector.hxx
  116.             mswindow.hxx -> mswindow.hxx
  117.             graph.mak    -> graph.mak
  118.             *.dat        -> *.dat
  119.             
  120. 5. Sample Data files for the definition of graphs    
  121.     g.dat
  122.     g20.dat
  123.  
  124.  
  125.  
  126.             
  127. Definitions of graph description files
  128. ======================================
  129.  
  130. The layout program expects the input data in a text file and also
  131. generates output file in the same format during the termination.  This
  132. file defines a weighted graph to be arranged in a easy-to-understand,
  133. programming language like way.
  134.  
  135. The definition language consists of
  136.  
  137. keywords: NAME, POSITION, TYPE, RELATIONS, OF, NODE, RELATION, RELATED, TO,
  138. --------  WITH, INTENSITY, END, MOVEABLE, FIXED
  139. Keywords should be specified by capital letters.
  140.  
  141. operators:
  142. --------- 
  143.       = :
  144.           
  145. string variables:
  146. -----------------
  147.           Any ASCII character string, having maximal length of 10 and which
  148.           does not contain characters "= : # space tab newline"
  149.  
  150. real variables:
  151. ---------------
  152.           For positions the range (0..1000.0, 0..1000.0) is allowed and for
  153.           weights (relation intensity) the range (-10.0..10.0) is permitted.
  154.           
  155. comments:
  156. ---------
  157.           The characters following a # character as far as the end of line
  158.           are assumed to form a comment
  159.  
  160. Keywords, variables and comments should be separated by whitespace characters
  161. (space, tabulator, newline) or operators.
  162.  
  163.  
  164. The basic structure of Graph definition File:
  165.  
  166.                        node definition
  167.                        node definition
  168.                        .
  169.                        .
  170.                        .
  171.                        node definition
  172.                        
  173.                        node relation definition
  174.                        node relation definition
  175.                        .
  176.                        .
  177.                        .
  178.                        node relation definition
  179.                        
  180.  
  181. node definition ( position is optional ):                     
  182.       NAME = nodename [POSITION =  position] TYPE = nodetype
  183.                     
  184. nodename:                    
  185.       Any ASCII character string, having maximal length of 10 and which
  186.       does not contain characters "= : # space newline". This name must be
  187.       unique, that is only one node can have it.
  188.       
  189. position:
  190.       Two real values in the range of (0..1000.0)
  191.       
  192. nodetype:
  193.       FIXED or MOVEABLE
  194.       
  195.       
  196. node relation definition:
  197.       RELATIONS OF nodename NODE
  198.       relation definition
  199.       relation definition
  200.       .
  201.       .
  202.       .
  203.       relation definition
  204.       END
  205.  
  206. nodename:
  207.       Name of already declared node in node definition
  208.                
  209. relation definition:
  210.       RELATION relation : RELATED TO node WITH INTENSITY intensity
  211.       
  212. relation:
  213.       Any ASCII character string, having maximal length of 10 and which
  214.       does not contain characters "= : # space newline"
  215.       The name * means that no name is specified for this relation.
  216.  
  217. node:      
  218.       Name of already declared node in node definition
  219.  
  220. intensity:
  221.       A real value in the range of (-10.0 .. 10.0)
  222.  
  223. A relation between two nodes can be defined in the file several times.
  224. In this case the last definition is taken into consideration.
  225.  
  226. SAMPLE INPUT FILE
  227. -----------------
  228. #
  229. #    DEMO RELATION GROUP - I am a comment
  230. #
  231.  
  232. #
  233. #    DECLARATIONS OF NODES
  234. #
  235. NAME = n1 POSITION =  764.2 216.0 TYPE = FIXED
  236. NAME = n2 POSITION =  131.3 858.6 TYPE = FIXED
  237. NAME = n3 TYPE = MOVEABLE            # POSITION = x,y is optional
  238. NAME = n4 TYPE = MOVEABLE
  239. NAME = n5 TYPE = MOVEABLE
  240. NAME = n6 TYPE = MOVEABLE
  241. NAME = n7 TYPE = MOVEABLE
  242. NAME = n8 TYPE = MOVEABLE
  243. NAME = n9 POSITION =  688.0 587.1 TYPE = MOVEABLE
  244.  
  245. #
  246. #    DECLARATIONS OF RELATIONS
  247. #
  248. RELATIONS OF n1 NODE
  249. RELATION r12 : RELATED TO n2 WITH INTENSITY 3.000000
  250. END
  251.  
  252. RELATIONS OF n2 NODE
  253. RELATION r23 : RELATED TO n3 WITH INTENSITY 2.000000 
  254. END
  255.  
  256. RELATIONS OF n3 NODE
  257. RELATION r31 : RELATED TO n1 WITH INTENSITY 6.000000
  258. END
  259.  
  260. RELATIONS OF n4 NODE
  261. RELATION r42 : RELATED TO n2 WITH INTENSITY 4.000000
  262. END
  263.  
  264. RELATIONS OF n5 NODE
  265. RELATION r53 : RELATED TO n3 WITH INTENSITY 3.000000
  266. #
  267. # * relation name means no name
  268. #
  269. RELATION * : RELATED TO n8 WITH INTENSITY 3.000000
  270. END
  271.  
  272. RELATIONS OF n7 NODE        # empty relation is also allowed
  273. END
  274.  
  275. RELATIONS OF n9 NODE 
  276. #
  277. # * relation name means no name
  278. #
  279. RELATION * : RELATED TO n8 WITH INTENSITY 3.000000
  280. END
  281.